package com.two.screen.water.balance.utils.eventbus

import org.greenrobot.eventbus.EventBus


/**
 * 创建者     Noel
 * 创建时间   2017/12/21 11:53
 * 描述	       将EventBus封装一层.
 */
class EventBusUtil {
    companion object {
        fun register(subscriber: Any) {
            if (!EventBus.getDefault().isRegistered(subscriber)) {
                EventBus.getDefault().register(subscriber)
            }
        }

        fun unregister(subscriber: Any) {
            EventBus.getDefault().unregister(subscriber)
        }

        fun sendEvent(event: Event<Any>) {
            EventBus.getDefault().post(event)
        }

        fun removeAllStickyEvents(subscriber: Any) {
            EventBus.getDefault().unregister(subscriber)
        }

        fun removeStickyEvent(event: Event<Any>) {
            EventBus.getDefault().removeStickyEvent(event)
        }

        fun sendStickyEvent(event: Event<Any>) {
            EventBus.getDefault().postSticky(event)
        }
    }
}